package com.learning.Map;

import java.util.HashMap;
import java.util.Map;

public class MyHashMap {
    public static void main(String[] args) {
        Map<String,Object> countryMap = new HashMap<>();
        countryMap.put("CN","中国");
        countryMap.put("JP","日本");
        countryMap.put("US","美国");
        countryMap.put("DE","德国");
        countryMap.put("MY","马来西亚");

        System.out.println("CN对应的国家是:"+countryMap.get("CN"));
        System.out.println("countryMap中一共有"+countryMap.size()+"对国家");
        System.out.println("countryMap中包含FR的key嘛？"+countryMap.containsKey("FR"));
        System.out.println("countryMap中包含CN的key嘛？"+countryMap.containsKey("CN"));
        countryMap.remove("CN","中国");
        System.out.println("打印countryMap中的所有键集"+countryMap.keySet());
        System.out.println("打印countryMap中的所有值集"+countryMap.values());
        System.out.println("同时打印countryMap中的Entry(键值对对象):"+countryMap.entrySet());
        countryMap.clear();//清空集合内容
        if (countryMap.isEmpty()==true){
            System.out.println("countryMap集合已清空");
        }
        countryMap.putIfAbsent("CN","中华人民共和国");
    }
}
